#include <bits/stdc++.h>

using namespace std;

void quick_sort(int *a, int p, int q) {
//递归终点
    if (p >= q)return;
//递归体
    int pivot = a[p];
    int i = p, j = q;
    while (i < j) {//Step1
        while (j > i && a[j] >= pivot)j--;
        while (j > i && a[i] <= pivot)i++;
        if (i >= j)break;
        swap(a[i], a[j]);

    }
    swap(a[p], a[i]);//Step2 哨兵就位
    quick_sort(a, p, i - 1);//
    quick_sort(a, i + 1, q);//
}

int main() {
    int a[] = {6, 1, 2, 7, 9, 3, 4, 5, 10, 8};
    int n = sizeof(a) / sizeof(a[0]);
    //sort(a,a+n);
    quick_sort(a, 0, n - 1); //Sort a from 0(inclusive) to n-1(inclusive)
    for (int i = 0; i < n; i++) {
        cout << a[i] << " ";
    }
    cout << endl;

    return 0;
}